package com.ljx.lambda.lambda02;

import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @author LJX
 * @Description: 构建方法引用 类名::new (args)->类名(args)
 * @Date: 2022/11/4 15:14
 * @Version 1.0
 */
public class ConstructerTest {
	public static void main(String[] args) {
		Function<String,People> function=(t)->{
			return new People(t);
		};
		People ljx = function.apply("ljx");
		System.out.println(ljx);

		Supplier<People> supplier=()->new People();
		People people = supplier.get();
		System.out.println(people);
	}
}

class People{
	private String name;
	private int age;

	public People() {
	}

	public People(String name, int age) {
		this.name = name;
		this.age = age;
	}

	public People(String t) {
		this.name=t;
	}

	@Override
	public String toString() {
		return "People{" +
				"name='" + name + '\'' +
				", age=" + age +
				'}';
	}
}